home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8574 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.th-darmstadt.de!news!enno
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How do I overload 'char*' in my class. Is it possible?
  5. Date: 13 Feb 1996 18:57:56 GMT
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Distribution: world
  8. Message-ID: <ENNO.96Feb13195757@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <4fp80t$odj@alcor.usc.edu>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: wawda@alcor.usc.edu's message of 12 Feb 1996 21:36:29 -0800
  12.  
  13. In article <4fp80t$odj@alcor.usc.edu> wawda@alcor.usc.edu (Abu Wawda) writes:
  14.  
  15.    I wrote a string class and now I would like to overload: char*
  16.    (character pointer), but can't figure out how to do it. I've already
  17.    overloaded the +, +=, ==, =, and some operator operators, but can't
  18.    figure how to do this (or even if it's possible). Basically I want
  19.    something like:
  20.  
  21.        char* operator ?? ()
  22.  
  23.    so that my string class can also return char*. Please help. Thanks,
  24.  
  25. You may define a conversion operator:
  26.  
  27.         operator const char* () const { return string_as_char_array; }
  28.  
  29.  
  30.         Enno
  31.